#include "ff.h"
#include "kernel/astralapi.h"
#include "strapi.h"

void cat(const char *name)
{
    char  buffer[101];
    f_getcwd(buffer, 100);
    strncat(buffer, "/", 100);
    strncat(buffer, name, 100);
    kprint("open %s\n",buffer);
    FIL file;
    FRESULT r = f_open(&file, name, FA_READ);
    if(FR_OK != r)
    {
        kprint("open %s failed with %d\n",name, r);
    }
    UINT br;
    while(!f_eof(&file))
    {
        f_read(&file, buffer, 100, &br);
        buffer[br] = '\0';
        kprint("%s",buffer);
    }
    kprint("\n");
}